home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / dolmorph / src / sub.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-29  |  3.7 KB  |  152 lines

  1. /*===========================================
  2.           DolphMorph(ドルフモーフ)
  3.  
  4.       モーフィング&変形アニメ作成ソフト
  5.  
  6.   モーフィングアルゴリズム: EAST 1994
  7.   インターフェース作成:     松内 良介 1994
  8. ===========================================*/
  9. /*
  10.     ファイル関係のちょっとした処理
  11.  
  12.     void    RM_putblock32k(char *buf, int x,int y,int width,int height)
  13. */
  14.  
  15. #include <stdio.h>
  16. #include <stdefs.h>
  17. #include <egb.h>
  18. #include <malloc.h>
  19. #include <stdlib.h>
  20. #include <msdos.cf>
  21. #include <memory.h>
  22. #include <interrup.cf>
  23. #include <math.h>
  24. #include <dos.h>
  25.  
  26. #include <winb.h>
  27. #include <te.h>
  28. #include <fntb.h>
  29. #include <gui.h>
  30. #include <file_dlg.h>
  31. #include <fnt.h>
  32.  
  33. #include "egbmac.h"
  34. #include "wgbmac.h"
  35.  
  36. #include "morph.h"
  37. #include "desktop.h"
  38. #include "guisub.h"
  39.  
  40. int resetfattr(char *fname)
  41. {
  42.     if (_dos_setfileattr(fname, _A_ARCH | _A_NORMAL) == 0)
  43.         return 0;
  44.     else
  45.         return -1;
  46. }
  47.  
  48. int fexist(char *fname)
  49. {
  50.     unsigned int b;
  51.     if (_dos_getfileattr(fname, &b) == 0)
  52.         return 1;
  53.     else
  54.         return 0;
  55. }
  56.  
  57. void trans_fname_ext(char *buf, char *fname, char *newext)
  58. /*
  59.     ファイル名 fname の拡張子を newext に置き換えたファイル名を返す
  60. */
  61. {
  62.     static char path_buf[_MAX_PATH];
  63.     char drive[_MAX_DRIVE], dir[_MAX_DIR], basename[_MAX_FNAME], ext[_MAX_EXT];
  64.     _splitpath(fname, drive, dir, basename, ext);
  65.     _makepath(buf, drive, dir, basename, newext);
  66. }
  67.  
  68. void add_fname_ext(char *buf, char *fname, char *newext)
  69. /*
  70.     ファイル名 fname に拡張子が無い場合、newext を拡張子として加える
  71. */
  72. {
  73.     char drive[_MAX_DRIVE], dir[_MAX_DIR], basename[_MAX_FNAME], ext[_MAX_EXT];
  74.     _splitpath(fname, drive, dir, basename, ext);
  75.     if (ext[0] == '\0')
  76.         _makepath(buf, drive, dir, basename, newext);
  77.     else
  78.         _makepath(buf, drive, dir, basename, ext);
  79. }
  80.  
  81. /*--------------------------------------------------------*/
  82. /*                     裏画面への描画                     */
  83. /*--------------------------------------------------------*/
  84.  
  85.     void RM_putblock32k(char *buf, int x,int y,int width,int height)
  86.     {
  87.         typedef struct {
  88.             short    x1,y1,x2,y2;
  89.         } VIEW;
  90.         VIEW view;
  91.         EGB_writePage(guiEgbPtr, 1);
  92.         WINCTRL *pCtrl;
  93.         MMI_GetControl(&pCtrl);
  94.         if (pCtrl->clip == NULL)
  95.         {
  96.             view.x1 = 0;
  97.             view.y1 = 0;
  98.             view.x2 = 319;
  99.             view.y2 = 239;
  100.             EGB_viewport(guiEgbPtr, (char*)&view);
  101.             EGB_PUTBLOCK(guiEgbPtr, buf, x,y, width,height,1);
  102.         }
  103.         else
  104.         {
  105.             WINCLIP *pClip;
  106.             Rect imageRect;
  107.             imageRect.left  = x*2;
  108.             imageRect.up    = y*2;
  109.             imageRect.right = x*2 + width*2 - 1;
  110.             imageRect.down  = y*2 + width*2 - 1;
  111.             for (pClip = pCtrl->clip;  pClip != NULL;  pClip=pClip->nextClip)
  112.             {
  113.                 Rect clipRect;
  114.                 clipRect = *(Rect*)&pClip->fr;
  115.                 if (SectRect(&clipRect, &imageRect))
  116.                 {
  117.                     view.x1 = (pClip->fr.lupx) / 2;
  118.                     view.y1 = (pClip->fr.lupy) / 2;
  119.                     view.x2 = (pClip->fr.rdwx+1) / 2;
  120.                     view.y2 = (pClip->fr.rdwy+1) / 2;
  121.                     EGB_viewport(guiEgbPtr, (char*)&view);
  122.                     EGB_PUTBLOCK(guiEgbPtr, buf, x,y, width,height, 1);
  123.                 }
  124.             }
  125.         }
  126.         EGB_writePage(guiEgbPtr, 0);
  127.         view.x1 = 0;
  128.         view.y1 = 0;
  129.         view.x2 = 639;
  130.         view.y2 = 479;
  131.         EGB_viewport(guiEgbPtr, (char*)&view);
  132.     }
  133.  
  134. /*--------------------------------------------------------*/
  135. /*             アラートとしてウィンドウを表示             */
  136. /*--------------------------------------------------------*/
  137.  
  138.     void MORPH_dispWinAlert(int idWin)
  139.     {
  140.         RM_moveCenter(idWin);
  141.         MTL_setFlagObj(idDesktopSelectiveHyper, MS_UNSELECT) ;
  142.         MMI_SendMessage(idWin, MM_ATTACH, 1, idDesktopAlertHyper);
  143.         MMI_SendMessage(idWin, MM_SHOW, 0);
  144.     }
  145.     
  146.     void MORPH_eraseWinAlert(int idWin)
  147.     {
  148.         MMI_SendMessage(idWin, MM_ERASE, 0);
  149.         MMI_SendMessage(idWin, MM_DETACH, 0);
  150.         MTL_resetFlagObj(idDesktopSelectiveHyper, ~MS_UNSELECT) ;
  151.     }
  152.